﻿<UserControl x:Class="AutomationMLMapper.Controls.RoleClassListControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:MarkupExtensions="clr-namespace:AutomationMLMapper.Controls.MarkupExtensions"
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:AutomationMLMapper.Controls"
			 xmlns:ConvertersAndTemplateSelectors="clr-namespace:AutomationMLMapper.Controls.ConvertersAndTemplateSelectors"
			 xmlns:Properties="clr-namespace:AutomationMLMapper.Properties" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
   
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/AutomationMLMapper;component/StyleResources/ListStyle.xaml"/>
                <ResourceDictionary Source="/AutomationMLMapper;component/StyleResources/Templates.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <ConvertersAndTemplateSelectors:BoolToVisibilityConverter FalseValue="Collapsed" x:Key="btvc" />
        </ResourceDictionary>
    </UserControl.Resources>
    
    <Grid Background="Transparent">   
        
        <ListView IsSynchronizedWithCurrentItem="True" HorizontalAlignment="Stretch"
			 Name="ListOfRoles" DataContext="{Binding RolesCollection}"
                  VirtualizingStackPanel.IsVirtualizing="True"
                  VirtualizingStackPanel.VirtualizationMode="Recycling"
                  ScrollViewer.IsDeferredScrollingEnabled="True"
			 ItemsSource="{Binding RelativeSource={RelativeSource Self}, Path=DataContext.View}" Margin="0,2,0,0" >

            <ListView.View>
                <GridView>

                    <GridViewColumn Width="Auto" CellTemplate="{StaticResource NameOutputTemplate}" HeaderContainerStyle="{StaticResource ColumnHeaderStyle}">
                        <GridViewColumn.HeaderTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="{MarkupExtensions:ImageResolution Source=RC.ico, Size=24}"></Image>
                                    <TextBlock Margin="5,0,0,0" Text="RoleClass"></TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </GridViewColumn.HeaderTemplate>
                    </GridViewColumn>

                    <GridViewColumn Width="Auto"  HeaderContainerStyle="{StaticResource ColumnHeaderStyle}">
                        <GridViewColumn.HeaderTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="/AutomationMLMapper;component/Images/ARC.ico"></Image>
                                    <TextBlock Margin="5,0,0,0" Text="Ancestor RoleClass"></TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </GridViewColumn.HeaderTemplate>
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding ParentName}" Foreground="#FFB10000"></TextBlock>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>

                    <GridViewColumn x:Name="RoleAttributesColumn" Width="Auto" HeaderContainerStyle="{StaticResource ColumnHeaderStyle}">
                        <GridViewColumn.HeaderTemplate>
                            <DataTemplate>
                                <local:CollapsibleColumnHeader HeaderImageSource="{MarkupExtensions:ImageResolution Source=AT.ico, Size=16}"
															   ShowColumn="{Binding ElementName=ListOfRoles, Mode=TwoWay,  Path=DataContext.ShowRoleAttributes}"
															   ExpandColumn="{Binding ElementName=ListOfRoles, Mode=TwoWay, Path=DataContext.ExpandClassAttributes}"
															   HeaderToolTip="Show Attributes of the RoleClass" HeaderName="Attributes" 
                                                               Column="{Binding ElementName=RoleAttributesColumn}">
                                </local:CollapsibleColumnHeader>
                            </DataTemplate>
                        </GridViewColumn.HeaderTemplate>
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <local:CAEXCollectionView AllowAdd="False" AllowDelete="False" AllowEditElement="False"
													 Visibility="{Binding ElementName=ListOfRoles, Path=DataContext.ShowRoleAttributes, Converter={StaticResource btvc}}" 
													 DataContext="{Binding AttributesCollection}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>

            <ListView.GroupStyle>
                <GroupStyle ContainerStyle="{StaticResource ListGroupStyle}">
                </GroupStyle>
            </ListView.GroupStyle>
        </ListView>
    </Grid>
</UserControl>
